package controller.user;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.UserService;
import service.impl.UserServiceImpl;
import utils.AJAXResult;
import utils.ResponseBodyUtil;


public class Delete extends HttpServlet {
	private static final long serialVersionUID = 1L;

	private UserService userService = new UserServiceImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String sid = request.getParameter("id");
		AJAXResult result = new AJAXResult();		
		try {
			Integer id = Integer.parseInt(sid);
			userService.deleteUserById(id);
			result.setSuccess(true);
		} 
		catch ( Exception e ) {
			e.printStackTrace();
			result.setSuccess(false);
		}
		
		ResponseBodyUtil.sendJsonObject(response, result);
	}

}
